home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK2.toast / Development Kits / QuickTake Digital Camera / MyQuickTakeApp 1.0.1TC7 ƒ / Headers / CmDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-06  |  19.1 KB  |  428 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------------------------
  2.     CmDriver        Version : 2.0 GM
  3.  
  4.     Copyright © 1994 by Apple Computer, Inc. All rights reserved.
  5.     Copyright © 1994 by Eastman Kodak Company, All rights reserved.
  6.     
  7.     Apple    Paul Hangas
  8.     Kodak    Takeshi Domen
  9.  
  10.      8/26/94    Version 2.0 d1 is the first release to Nimbus driver.
  11.                  No changes added excpet version of the driver.
  12.      9/12/94    Version 2.0 d2
  13.                  Debugged kCmDecompTableSize value from 98 to 176.
  14.      9/26/94    Version 2.0 a1c1
  15.                 kCmDecompTableSize100 and kCmDecompTableSize150 were added instead of 
  16.                 kCmDecompTableSize. And these size are below.
  17.                 #define kCmDecompTableSize100 98
  18.                 #define kCmDecompTableSize150 174
  19.                 The previous version supported it 176. But it was not good.
  20.                 The correct size of kCmDecompTableSize to Nimbus is 174.
  21.                 Also next beacon parameter were added as macro value.
  22.                 #define kbeaconParamQT100i 0x0101
  23.                 #define kbeaconParamQT100t 0x0100
  24.                 #define kbeaconParamQT150  0x0200
  25.     10/13/94    Version 2.0 a2
  26.                 The PictureMode constants were renamed as below:
  27.                 kCmColorQ -> kCmLoRes, kCmColor -> kCmHiRes.
  28.     10/28/94    Version 2.0 b1c1
  29.                 To meet changing of GeoPort strategy,the fields of CmPortInfo
  30.                 structure were changed from familyID and deviceID to manufacturerID,
  31.                 and from beaconParam to productID.
  32.                 Also the Manufacturer ID and Product ID were defined as constants.
  33.                 #define kCmManufacturerID100 0x0101  -- for Venus
  34.                 #define kCmManufacturerID150 0x00c8  -- for Nimbus
  35.  
  36.                 #define kProductID100i    0x0101
  37.                 #define kProductID100t    0x0100    
  38.                 #define kProductID150    0x0001
  39.     11/11/94    Version 2.0 b1c2
  40.                 Added error constant, kCmDrvrVersionError when QuickTake™ 100 driver is found
  41.                 and QuickTake™ 150 driver is not found.
  42.     12/ 1/94    Version 2.0 b2            
  43.     12/15/94    Version 2.0 f1c1
  44.      1/ 9/95    Version 2.0 GM
  45. ------------------------------------------------------------------------------------------------*/
  46. #ifndef __CmDriver_h__
  47. #define __CmDriver_h__
  48.  
  49. #ifndef __DEVICES__
  50. #include <Devices.h>
  51. #endif
  52.  
  53. /*----------------------- Camera Error Code --------------------------*/
  54. /* ErrorCategory  "error" */
  55. #define        kCmErNoError                    0x00
  56. #define        kCmErNoBattery                    0x01
  57. #define        kCmErMemoryFull                    0x02
  58. #define        kCmErFlashNotReady                0x03
  59. #define        kCmErImageMemoryDefect            0x04
  60. #define        kCmErAttention                    0x05
  61. #define        kCmErParityError                0x06
  62. #define        kCmErTimeoutError                0x07
  63. #define        kCmErHardwareError                0x08
  64. #define        kCmErBadParameter                0x09
  65. #define        kCmErBadPictureNumber            0x0A
  66. #define        kCmErUnknownError                0xFF
  67.  
  68. /*--------------------------------------------------------------------*/
  69. /* ConstantName "diagnosticsCode" */
  70. #define        kCmErNoError                    0x00
  71. #define        kCmErNoBattery                    0x01
  72. #define        kCmErMemoryFull                    0x02
  73. #define        kCmErFlashNotReady                0x03
  74. #define        kCmErImageMemoryDefect            0x04
  75. #define        kCmErCommandAborted                0x18
  76. #define        kCmErParityError                0x06
  77. #define        kCmErTimeoutError                0x07
  78. #define        kCmErGeneralHWError                0x0B
  79. #define        kCmErCPUError4Bit                0x0C
  80. #define        kCmErCPUError8Bit                0x0D
  81. #define        kCmErDSPError                    0x0E
  82. #define        kCmErFrameMemoryError            0x0F
  83. #define        kCmErTooManyImageMemoryDefects    0x19
  84. #define        kCmErImageMemoryError            0x10
  85. #define        kCmErInvalidCmdCode             0x11
  86. #define        kCmErInvalidControlCmd            0x12
  87. #define        kCmErInvalidCmdData                0x13
  88. #define        kCmErInvalidData                0x14
  89. #define        kCmErBadPicNumImage                0x16
  90. #define        kCmErBadPicNumInfo                0x17
  91.  
  92. /*----------------------------------- Error Code ----------------------------------------------*/
  93.  
  94. #define        kCmCameraError                    -6200
  95. #define        kCmAIPError                        kCmCameraError -1
  96. #define        kCmAlreadyOpenError                kCmCameraError -2
  97. #define        kCmANIPError                    kCmCameraError -3
  98. #define        kCmBadArgError                    kCmCameraError -4
  99. #define        kCmCurrentlyConnectedError        kCmCameraError -5
  100. #define        kCmCameraNotFoundError            kCmCameraError -6
  101. #define        kCmHandshakeError                kCmCameraError -7
  102. #define        kCmNotConnectedError            kCmCameraError -8
  103. #define        kCmNoMemoryError                kCmCameraError -9
  104. #define        kCmNoSuchPortError                kCmCameraError -10
  105. #define        kCmNotOpenError                    kCmCameraError -11
  106. #define        kCmProtocolError                kCmCameraError -12
  107. #define        kCmDriverNotLoadedError            kCmCameraError -13
  108. #define        kCmCommError                    kCmCameraError -14
  109. #define        kCmDrvrVersionError                kCmCameraError -15
  110.  
  111. #define        noErr                            0
  112.  
  113. /*----------------------------------------------------------------------------------------------*/
  114. /* CmSetPictureMode */
  115. #define        kCmHiRes            0x10
  116. #define        kCmLoRes            0x20
  117.  
  118. /* CmSetFlashMode */
  119. #define        kCmFlashOn            0x02
  120. #define        kCmFlashOff            0x01
  121. #define        kCmFlashAuto        0x00
  122.  
  123. /* CmSetOwnerName */
  124. #define        kCmOwnerNameLength        32
  125.  
  126. /*----------------------------------------------------------------------------------------------*/
  127. #define        kCmDecompTableSize100        98
  128. #define        kCmDecompTableSize150        174
  129.  
  130. /*----------------------------------------------------------------------------------------------*/
  131. /* Constants for application */
  132. #define        kPowerAdapter            140        // values >= 140 mean a power adapter is connected
  133.  
  134. // Battery Icon constants for simulating the Battery Icon on the back of the camera
  135. #define        kBatteryIconFull        86        // values >= 86 should show a battery full icon
  136. #define        kBatteryIconHalf        80        // values 80 - 85 should show a battery half icon
  137. // values below kBatteryIconHalf should show a battery empty icon
  138. // Battery Icon constants for a more detailed view of hte Battery levels
  139. #define        kBatteryRangeFull        95        // full battery icon
  140. #define        kBatteryRangeEmpty        75        // empty battery icon
  141. /*----------------------------------------------------------------------------------------------*/
  142. /* Define QuickTake Manufacturer ID */// Changed 10/24/94 by Domen
  143. #define     kCmManufacturerID100     0x0101
  144. #define     kCmManufacturerID150     0x00c8
  145.  
  146. /*----------------------------------------------------------------------------------------------*/
  147. /* Define QuickTake Manufacturer ID */// Changed 10/24/94 by Domen
  148. #define        kProductID100i             0x0101
  149. #define     kProductID100t             0x0100
  150. #define     kProductID150              0x0001
  151. //--------------------------------------------------------------------------------------------------
  152.  
  153. typedef struct {
  154.     long                        currentA5;
  155.     ParamBlockRec                paramBlock;
  156.     Boolean                        connectedFlag;
  157. } CmCameraData;
  158.  
  159. /*----------------------------------------------------------------------------------------------*/
  160.  
  161. typedef CmCameraData*        CameraData;
  162. typedef CameraData*            CameraDataPtr;
  163. typedef unsigned char*        BufferPtr;
  164. typedef unsigned long*        LongPtr;
  165. typedef short*                shortPtr;
  166.  
  167. /*----------------------------------------------------------------------------------------------*/
  168.  
  169. typedef struct {
  170.     short    version;
  171. } CmStdFeatures, *CmStdFeaturesPtr;
  172.  
  173. typedef struct {
  174.     Handle            portIcon;
  175.     StringHandle    portName;
  176.     unsigned long    portStatus;
  177.     StringHandle    appName;
  178.     unsigned short    manufacturerID; // Changed 10/24/94 by Domen
  179.     unsigned short    productID;        // Changed 10/24/94 by Domen
  180.     Handle            portConfig;
  181.     unsigned long    DataSpeed;
  182. } CmPortInfo, *CmPortInfoPtr, **CmPortInfoHandle;
  183.  
  184. typedef CmPortInfoHandle*    CmPortInfoHandlePtr;
  185.  
  186. /*----------------------------------------------------------------------------------------------*/
  187.  
  188. typedef struct {
  189.     char            vendorName[8];                /* Apple Computer */
  190.        char            productIdentification[16];    /* Apple Digital Camera */
  191.     unsigned char    hardwareVersion[2];            /* 1.01 - byte[1]=01, byte[0]=01 */
  192.     unsigned char    firmwareVersion[2];            /* 1.10 - byte[1]=01, byte[0]=10 */
  193. } CmProductInfo, *CmProductInfoPtr;
  194.   
  195.  
  196. typedef struct {
  197.     unsigned char    month;
  198.     unsigned char    day;
  199.     unsigned char    year;
  200.     unsigned char    hour;
  201.     unsigned char    minute;
  202.     unsigned char    second;
  203. } CmDateAndTime, *CmDateAndTimePtr;
  204.  
  205.  
  206. typedef struct {
  207.     unsigned char    transferRate;
  208.     unsigned char    configuration;         /* HostMode */
  209.     unsigned char    timeOut;
  210. } CmInterface;
  211.  
  212.  
  213. typedef struct {
  214.     unsigned char        batteryStatus;
  215.     unsigned short        noPicturesTaken;
  216.     unsigned short        noPictureImageAvailable;
  217.     unsigned short        fullImageWidth;
  218.     unsigned short        fullImageHeight;
  219.     unsigned short        thumbnailImageWidth;
  220.     unsigned short        thumbnailImageHeight;
  221.     CmDateAndTime        cameraDateAndTime;
  222.     unsigned char        flashMode;
  223.     unsigned short        exposureTime;
  224.     unsigned short        FNumber;
  225.     unsigned char        pictureMode;    /* bit0=0 Full Size, bit0=1 1/4 size, bit4=0  B&W, bit4=1 Color */
  226.     unsigned char        reserved;
  227.     unsigned char          fullImageDatCompMode;
  228.       unsigned char        thumbImageDatCompMode;
  229.     unsigned long        totalMemorySize;
  230.     unsigned long        freeMemorySize;
  231.     char                ownerName[32];    /* CameraID */
  232.     unsigned char        CCDSensorType;
  233.     CmInterface            hostInterface;
  234.     unsigned char        cameraInformationBytes[6];
  235.     unsigned char        compDecompParamVersion[4];
  236.     unsigned char        colorMatrixVersion[4];
  237.     unsigned char        spareImageMemoryBlock;
  238.     unsigned short        noBasePicturesTaken;
  239.     unsigned short        noQuarterPicturesTaken;
  240.     unsigned char        sleepDelay;
  241. } CmCameraInfo,  *CmCameraInfoPtr;
  242.  
  243. //typedef CmCameraInfo*;
  244.   
  245. typedef struct  {
  246.     unsigned short        pictureNo;
  247.     unsigned long        imageDataSize;
  248.     unsigned short        width;
  249.     unsigned short        height;
  250.     CmDateAndTime        dateAndTime;
  251.     unsigned char        flashMode;
  252.     unsigned short        exposureTime;
  253.     unsigned short        FNumber;
  254.     unsigned char        pictureMode;    /* bit0=0 Full Size, bit0=1 1/4 size, bit4=0  B&W, bit4=1 Color */
  255.     unsigned char        dataCompressionMode;    /* CFA=0, ADPCM=1, ColorDiff=2 */
  256.     unsigned char        defectiveFlag;
  257. } CmPictureInfo, *CmPictureInfoPtr;
  258.  
  259. typedef struct {
  260.     unsigned char        colorMatrixVersion[4];
  261.     double                colorCorrectionMatrix[12];
  262. } CmColorMatrix, *CmColorMatrixPtr;
  263.  
  264. /*----------------------------------------------------------------------------------------------*/
  265. typedef void (CallbackProc) ();
  266.                             /* This is the completion routine definition.  This is called from
  267.                                the driver when an async function is called. 
  268. /*----------------------------------------------------------------------------------------------*/
  269. typedef CallbackProc* CmAsyncCompletionRoutinePtr;
  270. /*----------------------------------------------------------------------------------------------*/
  271.  pascal OSErr CmOpenDriver(CameraData* cameraData);
  272.                             /* Open the Camera Driver.  Driver memory is allocated and High
  273.                                Speed Serial code is loaded. */
  274. /*----------------------------------------------------------------------------------------------*/
  275.  pascal OSErr CmCloseDriver(CameraData cameraData);
  276.                              /* Close the Camera Driver.  Driver memory is disposed and High
  277.                                Speed Serial code is disposed. */
  278. /*----------------------------------------------------------------------------------------------*/
  279.  pascal OSErr CmGetStdFeatures(CameraData cameraData,
  280.                                      CmStdFeaturesPtr stdFeaturesPtr,
  281.                                      short length);
  282.                              /* Get the standard features of the camera driver.  The
  283.                                'CmStdFeatures' record will be filled up to the 'length'. */
  284. /*----------------------------------------------------------------------------------------------*/
  285.  pascal OSErr CmGetPortInfo(CameraData cameraData,
  286.                                   unsigned long index,
  287.                                   CmPortInfoHandlePtr portInfoHandle);
  288.                             /* Get information about the port specified by 'index' and return
  289.                                a Handle to the 'CmPortInfo' info.  If there is no port for that
  290.                                'index' the Handle will be NULL. */
  291. /*----------------------------------------------------------------------------------------------*/
  292.  pascal OSErr CmDisposePortInfo(CameraData cameraData,
  293.                                       CmPortInfoHandle portInfoHandle);
  294.                             /* Dispose the CmPortInfo record and the Handles contained within
  295.                                it. */
  296. /*----------------------------------------------------------------------------------------------*/
  297.  pascal OSErr CmConnect(CameraData cameraData,
  298.                               CmPortInfoHandle portInfoHandle);
  299.                             /* Connect to the camera on the port specified by the CmPortInfo. */
  300. /*----------------------------------------------------------------------------------------------*/
  301.  pascal OSErr CmDisconnect(CameraData cameraData);
  302.                             /* Disconnect from the camera. */
  303. /*----------------------------------------------------------------------------------------------*/
  304.  pascal OSErr CmCheckIfReady(CameraData cameraData);
  305.                             /* Check to see if the camera is ready for commands. */
  306. /*----------------------------------------------------------------------------------------------*/
  307.  pascal OSErr CmRestoreDefaults(CameraData cameraData);
  308.                             /* Restore the camera to the default settings. */
  309. /*----------------------------------------------------------------------------------------------*/
  310.  pascal OSErr CmGetErrorInfo(CameraData cameraData,
  311.                                    shortPtr category,
  312.                                    shortPtr detail);
  313.                             /* Get camera hardware specific detailed error information. */
  314. /*----------------------------------------------------------------------------------------------*/
  315.  pascal OSErr CmGetProductInfo(CameraData cameraData,
  316.                                      CmProductInfoPtr productInfo);
  317.                             /* Get camera hardware product information.  This includes the 
  318.                                vendor name, product name, and version */
  319. /*----------------------------------------------------------------------------------------------*/
  320.  pascal OSErr CmTakePicture(CameraData cameraData,
  321.                                   Boolean timerOn);
  322.                             /* Take a picture.  The camera will take the picture in Timer Mode
  323.                                if 'timerOn' is true. */
  324. /*----------------------------------------------------------------------------------------------*/
  325.  pascal OSErr CmTakePictureAsync(CameraData cameraData,
  326.                                        Boolean timerOn,
  327.                                        CmAsyncCompletionRoutinePtr CmAsyncCompletionRoutine);
  328.                             /* Take a picture.  The camera will take the picture in Timer Mode
  329.                                if 'timerOn' is true.
  330.                                The 'completionRoutine' is a pointer to a routine
  331.                                that is called from the driver when the driver completes. */
  332. /*----------------------------------------------------------------------------------------------*/
  333.  pascal OSErr CmSelfTest(CameraData cameraData);
  334.                             /* Camera will perform a diagnostic self test. */
  335. /*----------------------------------------------------------------------------------------------*/
  336.  pascal OSErr CmGetCameraInfo(CameraData cameraData,
  337.                                     CmCameraInfoPtr cameraInfo);
  338.                             /* Get the camera information. */
  339. /*----------------------------------------------------------------------------------------------*/
  340.  pascal OSErr CmGetPictureInfo(CameraData cameraData,
  341.                                      unsigned short pictureNo,
  342.                                      CmPictureInfoPtr pictureInfo);
  343.                             /* Get the picture information for the 'pictureNo' image. */
  344. /*----------------------------------------------------------------------------------------------*/
  345.  pascal OSErr CmGetThumbnailImage(CameraData cameraData,
  346.                                         unsigned short pictureNo,
  347.                                         BufferPtr thumbnailBuffer,
  348.                                         unsigned long numberOfBytesToRead,
  349.                                         Boolean firstRead,
  350.                                         LongPtr actualBytes);
  351.                             /* Get the thumbnail image specified by 'pictureNo'.  
  352.                                To read the entire image in a single call, set
  353.                                'numberOfBytesToRead' = the image size, 'firstRead' = true,
  354.                                and 'thumbnailBuffer' = pointer to a buffer; then call
  355.                                'CmGetThumbnailImage'.
  356.                                To read the entire image with multiple calls, set
  357.                                'numberOfBytesToRead' = the first number of bytes to read
  358.                                 (this has to be a multiple of 512),
  359.                                'firstRead' = true, and 'thumbnailBuffer' = pointer to a buffer;
  360.                                then call 'CmGetThumbnailImage'.  The remaining data may be read
  361.                                by calling 'CmGetThumbnailImage' multiple times with 'firstRead'
  362.                                = false, 'numberOfBytesToRead' = the next number of bytes to read,
  363.                                and 'thumbnailBuffer' = pointer into the new location in the
  364.                                buffer. 
  365.                                The 'actualBytes' contains the number of bytes actually read. */
  366. /*----------------------------------------------------------------------------------------------*/
  367.  pascal OSErr CmGetFullSizeImage(CameraData cameraData,
  368.                                        unsigned short pictureNo,
  369.                                        BufferPtr imageBuffer,
  370.                                        unsigned long numberOfBytesToRead,
  371.                                        Boolean firstRead,
  372.                                        LongPtr actualBytes);
  373.                             /* Get the full size image specified by 'pictureNo'.  
  374.                                To read the entire image in a single call, set
  375.                                'numberOfBytesToRead' = the image size, 'firstRead' = true,
  376.                                and 'imageBuffer' = pointer to a buffer; then call
  377.                                'CmGetFullSizeImage'.
  378.                                To read the entire image with multiple calls, set
  379.                                'numberOfBytesToRead' = the first number of bytes to read
  380.                                 (this has to be a multiple of 512),
  381.                                'firstRead' = true, and 'imageBuffer' = pointer to a buffer;
  382.                                then call 'CmGetFullSizeImage'.  The remaining data may be read
  383.                                by calling 'CmGetFullSizeImage' multiple times with 'firstRead'
  384.                                = false, 'numberOfBytesToRead' = the next number of bytes to read,
  385.                                and 'imageBuffer' = pointer into the new location in the
  386.                                buffer. 
  387.                                The 'actualBytes' contains the number of bytes actually read. */
  388. /*----------------------------------------------------------------------------------------------*/
  389.  pascal OSErr CmErase(CameraData cameraData);
  390.                             /* Erase the images from the camera's memory. */
  391. /*----------------------------------------------------------------------------------------------*/
  392.  pascal OSErr CmEraseAsync(CameraData cameraData,
  393.                                  CmAsyncCompletionRoutinePtr CmAsyncCompletionRoutine);
  394.                             /* Erase the images from the camera's memory.
  395.                                The 'completionRoutine' is a pointer to a routine
  396.                                that is called from the driver when the driver completes. */
  397. /*----------------------------------------------------------------------------------------------*/
  398.  pascal OSErr CmSetDateAndTime(CameraData cameraData,
  399.                                      CmDateAndTimePtr dateAndTime);
  400.                             /* Set the camera's date and time. */
  401. /*----------------------------------------------------------------------------------------------*/
  402.  pascal OSErr CmSetOwnerName(CameraData cameraData,
  403.                                    BufferPtr ownerName);
  404.                             /* Set the camera's owner name.  This is a 32 character string. */
  405. /*----------------------------------------------------------------------------------------------*/
  406.  pascal OSErr CmSetPictureMode(CameraData cameraData,
  407.                                      unsigned char pictureMode);
  408.                             /* Set the 'pictureMode' of the camera. */
  409. /*----------------------------------------------------------------------------------------------*/
  410.  pascal OSErr CmSetFlashMode(CameraData cameraData,
  411.                                    unsigned char flashOn);
  412.                             /* Set the flash mode on or off. */ 
  413. /*----------------------------------------------------------------------------------------------*/
  414.  pascal OSErr CmGetDecompTable(CameraData cameraData,
  415.                                      BufferPtr ipmInfo);
  416.                             /* Get the data compression/decompression table */
  417. /*----------------------------------------------------------------------------------------------*/
  418.  pascal OSErr CmGetColorCorrectionMatrix(CameraData cameraData,
  419.                                                CmColorMatrixPtr colorMatrix);
  420.                             /* Get the camera color correction matrix */
  421. /*----------------------------------------------------------------------------------------------*/
  422.  pascal OSErr CmSetSleep(CameraData cameraData,
  423.                                short sleepDelay);
  424.                             /* Set the sleep delay (while connected to a computer) of the camera */
  425. /*----------------------------------------------------------------------------------------------*/
  426.  
  427. #endif
  428.